# coding = utf-8
# !/usr/bin/env python
'''
Created on 2017-11-24
'''

import os.path
import logging

class LogUtil():
    def __init__(self, logPath):
        self.logPath = logPath
        logging.basicConfig(level=logging.INFO,
                            format='%(asctime)s[line:%(lineno)d] %(levelname)s %(message)s',
                            datefmt='%Y %b %d %a,%H:%M:%S',
                            filename=logPath,
                            filemode='w')

    def dataToLogInfo(self, data):
        logging.info(data)

    def dataToLogWarning(self, data):
        logging.warning(data)

    def dataToLogError(self, data):
        logging.error(data)

if __name__ == '__main__':
    home = os.path.expanduser('~')
    log_path = os.path.join(home, 'Desktop/some.log')

    logger = LogUtil(log_path)

    logger.dataToLogInfo('This is log info.')
    logger.dataToLogError('This is log error')
    logger.dataToLogWarning('This is log warning')

